package com.david.mydemo.ctl_ftp.controller;

import com.david.mydemo.ctl_ftp.model.AaaaLog;
import com.david.mydemo.ctl_ftp.service.ISysLogService;
import com.david.mydemo.util.MyResponse;
import com.david.mydemo.ctl_ftp.model.DataEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@ApiIgnore
@Api(value = "日志管理-SysLogController", tags = "日志管理-SysLogController")
@RestController
@RequestMapping(value = "/sysLog")
@Slf4j
public class SysLogController {

    @Autowired
    private ISysLogService sysLogService;

    /**
     * 登陆日志记录
     * @param log
     * @return
     */
    @PostMapping("/saveLogOn")
    @ApiOperation(value = "日志记录保存")
    public MyResponse saveLogOn(@RequestBody AaaaLog log) {
        int result = sysLogService.saveLogOn(log);
        if(result == 1) {
            return new MyResponse().success();
        } else {
            return new MyResponse().fail();
        }
    }

    /**
     * 查询日志记录
     * @param dataEntity
     * @return
     */
    @PostMapping("/queryAaaaLog")
    @ApiOperation(value = "查询日志记录")
    public MyResponse queryAaaaLog(@RequestBody DataEntity dataEntity) {
        List<AaaaLog> result = sysLogService.queryAaaaLog(dataEntity);
        return new MyResponse().success(result);
    }

}
